<form action="${ctx}/gateway/form" method="post" id="addGateway" enctype="multipart/form-data">
	<input type="hidden" name="gatewayId" value="${gatewayInfo.gatewayId!}" />
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label><span style="color: red">*</span>网关名称：</label>
			<input class="form-control" type="text" name="name" value="${gatewayInfo.name!}"  required />
		</div>
		<div class="col-sm-6">
			<label><span style="color: red">*</span>网关标识：</label>
			<input class="form-control" type="text" name="gwName" value="${gatewayInfo.gwName!}"  required />
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
		<label><span style="color: red">*</span>部署地区：</label>
			<select class="form-control" style="width: 120px;" name="provinceCode" >
				<option value="">--请选择--</option>
				<#list firstLevel as a>
					<option value="${a.code}" <#if gatewayInfo.provinceCode?? && a.code==gatewayInfo.provinceCode>selected</#if> >${a.city}</option>
				</#list>
			</select>
			<select class="form-control" style="width: 120px" name="cityCode" id="cityCode" required>
				<option value="">--请选择--</option>
				<#if secondLevel??>
					<#list secondLevel as a>
						<option value="${a.code}" <#if gatewayInfo.cityCode?? && a.code==gatewayInfo.cityCode>selected</#if> >${a.city}</option>
					</#list>
				</#if>
			</select>
		</div>
		<div class="col-sm-6">
			<label><span style="color: red">*</span>部署位置:</label>
			<select class="form-control" name="positionId"  required>
				<option value="">--请选择--</option>
				<#list positions as position>
					<option value="${position.id}" <#if gatewayInfo.positionId?? && position.id==gatewayInfo.positionId>selected</#if> >${position.name}</option>
				</#list>
			</select>
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label>网关品牌：</label>
			<select class="form-control" name="brandId" >
				<option value="">--请选择--</option>
				<#list brands as brand>
					<option value="${brand.id}" <#if gatewayInfo.brandId?? && brand.id==gatewayInfo.brandId>selected</#if> >${brand.name}</option>
				</#list>
			</select>
		</div>
		<div class="col-sm-6">
			<label>端口：</label>
           	<select class="form-control" style="width: 120px;" name="portNum" >
           	   <option value="">--请选择--</option>
           	   <#list portNums as k, v>
					<option value="${k}" <#if gatewayInfo.portNum?? && k==gatewayInfo.portNum?c>selected</#if> >${v}</option>
				</#list>
           	</select>
           	<select class="form-control" style="width: 120px;" name="portType" >
           	   <option value="">--请选择--</option>
           	   <#list portTypes as k, v>
					<option value="${k}" <#if gatewayInfo.portType?? && k==gatewayInfo.portType?c>selected</#if> >${v}</option>
				</#list>
           	</select>
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label>FTP用户名：</label>
			<input class="form-control" type="text" name="voxFtpUser" value="${gatewayInfo.voxFtpUser!}" />
		</div>
		<div class="col-sm-6">
			<label>FTP密码：</label>
			<input class="form-control" type="text" name="voxFtpPass" value="${gatewayInfo.voxFtpPass!}" />
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label>网关IP：</label>
			<input class="form-control" type="text" name="voxFtpIp" value="${gatewayInfo.voxFtpIp!}" />
		</div>
		<div class="col-sm-6">
			<label>服务器：</label>
			<select class="form-control" name="serverId" >
				<option value="">--请选择--</option>
				<#list servers as server>
					<option value="${server.serverId}" <#if gatewayInfo.serverId?? && server.serverId==gatewayInfo.serverId>selected</#if> >${server.serverName}</option>
				</#list>
			</select>
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label><span style="color: red">*</span>录音地址：</label>
			<input class="form-control" type="text" name="voxServerAddr" value="${gatewayInfo.voxServerAddr!}" required />
		</div>
		<div class="col-sm-6">
			<label><span style="color: red">*</span>授权数：</label>
			<input class="form-control" type="text" name="authorizedNum" value="${gatewayInfo.authorizedNum!}" required />
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-6">
			<label>公司软交换：</label>
			<select class="form-control width180" name="newSoftSwitch">
				<option value="0" <#if gatewayInfo?? && gatewayInfo.newSoftSwitch?? && gatewayInfo.newSoftSwitch = 0>selected</#if>>三汇</option>
				<option value="1" <#if gatewayInfo?? && gatewayInfo.newSoftSwitch?? && gatewayInfo.newSoftSwitch = 1>selected</#if>>不分离</option>
				<option value="2" <#if gatewayInfo?? && gatewayInfo.newSoftSwitch?? && gatewayInfo.newSoftSwitch = 2>selected</#if>>分离</option>
			</select>
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-12">
			<div class="SimInputBox" id="simGateways">
				<label>SIM卡网关：</label>
				<#list simGateways as simGateway>
					<span class="input-box">
						<input class="form-control" type="text" name="simGateway" value="${simGateway!}" />
						<i class="Delete hide"></i>
					</span>
				</#list>
			</div>
			<div class="SimOperate">
				<a href="javascript:addSimGateway();">添加</a>
			</div>
		</div>
	</div>
	<div class="form-group form-inline row">
		<div class="col-sm-12">
			<label>描述：</label>
			<textarea class="form-control" style="width: 80%;" rows="3" name="gwDesc">${gatewayInfo.gwDesc!}</textarea>
		</div>
	</div>
</form>

<script>
	$("#addGateway").validate();
	$("select[name='provinceCode']").change(function(){
		var provinceCode = $(this).val();
		$.ajax({
			url:"${ctx}/area/getCity?provinceCode="+provinceCode,
			dataType:"json",
			success:function(res){
				var citys = res.data;
				console.log(citys);
				$("#cityCode").find("option").remove();
				$("#cityCode").append("<option value=''>--请选择--</option>");
				for(var i=0; i<citys.length; i++){
					$("#cityCode").append("<option value='"+citys[i].code+"'>"+citys[i].city+"</option>");
				}
			}
		})
	});
	
	$("body").on('mouseover', "#simGateways :input, #simGateways .Delete", function(event){
		$(this).parent().find("i").removeClass("hide");
	});
	$("body").on('mouseout', "#simGateways :input", function(event){
		$(this).parent().find("i").addClass("hide");
		event.stopPropagation();
	});
	
	$("body").on('click',"#simGateways .Delete", function () {
		$(this).parent().remove();
	});
	
	function addSimGateway() {
		var html = '<span class="input-box">';
		html += '<input class="form-control" type="text" name="simGateway" value="${simGateway!}" />';
		html += '<i class="Delete hide"></i>';
		html += '</span>';
		$("#simGateways").append(html);
	}
	
	/* 
	$('#expirationTime').datepicker({
        autoclose: true,
        format: 'yyyy-mm-dd',
        language: 'zh-CN'
    });
	 */
</script>
